Skip to main content

Cookie based Authentication

With automation, most of the cases start with logging into the the application under test. But does this have to be repeated for every use case?

DevAssure provides the support to authenticate users based on cookie storage. While recording, the state can be stored in a file, and the same file can be loaded every time when there is a use case to be automated with an auth flow.

This enhances execution time of the test automation and also reduces test automation flakiness.

Record and save cookie information

After saving the recording

Save cookie information With DevAssure

Loading the state from the file while recording

Load cookie information With DevAssure while recording

Sample DevAssure Test Automation Code

Cookie based Authentication with DevAssure - Sample Test Automation code

In the above code, additional checks have been added to login with username and password if the tokens stored have expired. In subsequent executions, the new cookie state saved will be considered.

Sample DevAssure Test Automation Code for Multiple users

Cookie based Authentication with DevAssure - Sample Test Automation code